package com.zbf.tspring.springEvent;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationEvent;
import org.springframework.stereotype.Component;

/**
 * @author: LCG
 * @Date: 2022-04-16 11:21:03
 * @description: 事件发布器
 **/
@Component
public class MyEventPublisher implements ApplicationContextAware {

    private ApplicationContext applicationContext;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext=applicationContext;
    }

    /** 
     * @author: LCG
     * @date: 2022-04-16 16:20:06
     * @description:  发布事件方法
     */
    public void publishEvent(ApplicationEvent event){

        applicationContext.publishEvent(event);
    }
}
